package com.sunlands.deskmate.message.enums;

/**
 * @Author: anjunling@sunlands.com
 * @Description:
 * @Date: Create in 14:06 2018/6/14
 * @Modified By:
 */
public enum ProtocolEnum {

    HTTP("http"),
    HTTPS("https"),
    WEBSOCKET("websocket"),
    WEBSOCKETS("websockets");

    private String type;

    ProtocolEnum(String type) {
        this.type = type;
    }

    public String getType() {
        return type;
    }


    public static boolean contains(String type) {
        if (type == null) {
            return false;
        }

        try {
            ProtocolEnum protocolEnum = ProtocolEnum.valueOf(type.toUpperCase());
            if (protocolEnum == null) {
                return false;
            }
        } catch (IllegalArgumentException e) {
            return false;
        }

        return true;
    }
}
